package com.heima.admin.controller.v1;

import com.heima.admin.service.AdminChannelService;
import com.heima.apis.admin.IAdminClient;
import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannerlDto;
import com.heima.model.wemedia.pojos.WmChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/v1/channel")
public class AdminChannelController {

    @Autowired
    private IWemediaClient iWemedia;

    @Autowired
    private AdminChannelService adminChannelService;


    /**
     * 查询频道
     * @return
     */
    @GetMapping("/channels")
    public ResponseResult findAll(){
        return adminChannelService.findAll();
    }


    /**
     * 新增频道
     * @param wmChannel
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel) {
        return iWemedia.save(wmChannel);
    }

    

    /**
     * 修改频道
     * @param wmChannel
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel) {
        return iWemedia.update(wmChannel);
    }

    /**
     * 删除频道
     */
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id")Integer id){

        return iWemedia.delete(id);
    }

    /**
     * 查询列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult findByNamePage(@RequestBody ChannerlDto dto ){
        return iWemedia.findByNamePage(dto);
    }
}
